#include <string>
#include<vector>
#include<array>
#include<limits>
class Solution {
public:
    std::string minWindow(std::string s,std:: string t) {
        if (t.empty() || s.empty()) return "";
        int debt = t.size();
        int n = s.size();
        std::array<int,256> ss;
        int start =0;
        int ans = std::numeric_limits<int>::max();
        int nt = t.size();
        ss.fill(0);
        for (int i=0;i<nt;i++)
        {
            ss[t[i]]--;
        }
        for (int l = 0,r = 0 ;r<n;r++)
        {
            if (ss[s[r]]<0)
            {
                debt--;
            }
            ss[s[r]]++;
            if (debt <= 0)
            {
                while (ss[s[l]]>0)
                {
                    ss[s[l++]]--;
                }
              if (ans > r-l+1)
              {
                  ans = r-l+1;
                  start = l;
              }
            }
        }
        return debt<=0?s.substr(start,ans):"";
    }
};
